package com.app.newiptv.promote;

import com.app.newiptv.utils.APPLog;
import com.app.newiptv.utils.Sputil;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

import java.io.File;

public class BootAnimationHelper {


    public static void loadBootAnimation(String url, final String md5)
    {
        RequestParams params=new RequestParams(url);
        params.setSaveFilePath("/data/local/bootanimation.zip");
        params.setAutoResume(true);

        APPLog.printDebug(url+":"+md5);

        x.http().get(params, new Callback.ProgressCallback<File>() {
            @Override
            public void onWaiting() {

            }

            @Override
            public void onStarted() {

            }

            @Override
            public void onLoading(long total, long current, boolean isDownloading) {

                APPLog.printDebug("progress:"+current+"/"+total);
            }

            @Override
            public void onSuccess(File result) {
                APPLog.printDebug(result.getAbsolutePath()+":"+result.length());
                Sputil.putValue("boot_md5_code",md5);
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                APPLog.printThrowable(ex);
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });
    }
}
